using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class UICard_Item : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
{
    private static Color NormalColor = Color.white;
    private static Color SelectColor = new Color(0.4f, 0.75f, 1f, 1f);

    public Image CardImage;

    private bool isSelect;
    public bool IsSelect
    {
        get => isSelect;

        set
        {
            isSelect = value;
            if (isSelect)
            {
                CardImage.transform.localPosition = new Vector3(0, 80, 0);
            }
            else
            {
                CardImage.transform.localPosition = Vector3.zero;
            }
        }
    }

    private int cardID;

    public void Init(int cardID, CardDefine cardDefine)
    {
        this.cardID = cardID;
        CardImage.sprite = cardDefine.cardImage;
    }

    public void OnPointerClick(PointerEventData eventData)
    {
        UIMain_Panel.Instance.SelectCard(cardID);
    }

    public void OnPointerEnter(PointerEventData eventData)
    {
        CardImage.color = SelectColor;
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        CardImage.color = NormalColor;
    }



}
